Caption = "Cypher Text from above line becomes decrypted."
BeginProperty Font
Name = "System"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 285
Index = 3
Left = 900
TabIndex = 6
Top = 3015
Width = 4830
End
Begin VB.Label Label1
BackColor = &H00000000&
Caption = "Password becomes encrypted. You may also enter a previously encrypted password here."
BeginProperty Font
Name = "System"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 465
Index = 2
Left = 900
TabIndex = 5
Top = 1800
Width = 8700
End
Begin VB.Line Line1
BorderColor = &H0000FF00&
BorderWidth = 2
Index = 5
X1 = 630
X2 = 765
Y1 = 3240
Y2 = 3060
End
Begin VB.Line Line1
BorderColor = &H0000FF00&
BorderWidth = 2
Index = 4
X1 = 495
X2 = 630
Y1 = 3060
Y2 = 3240
End
Begin VB.Line Line1
BorderColor = &H0000FF00&
BorderWidth = 2
Index = 3
X1 = 630
X2 = 630
Y1 = 2790
Y2 = 3195
End
Begin VB.Line Line1
BorderColor = &H0000FF00&
BorderWidth = 2
Index = 2
X1 = 630
X2 = 765
Y1 = 2160
Y2 = 1980
End
Begin VB.Line Line1
BorderColor = &H0000FF00&
BorderWidth = 2
Index = 1
X1 = 495
X2 = 630
Y1 = 1980
Y2 = 2160
End
Begin VB.Line Line1
BorderColor = &H0000FF00&
BorderWidth = 2
Index = 0
X1 = 630
X2 = 630
Y1 = 1710
Y2 = 2115
End
Begin VB.Label Label1
BackColor = &H00000000&
Caption = "Enter Password Here"
BeginProperty Font
Name = "System"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 285
Index = 1
Left = 270
TabIndex = 4
Top = 945
Width = 2130
End
Begin VB.Label Label1
BackColor = &H00000000&
Caption = "WS_Encrypt"
BeginProperty Font
Name = "System"
Size = 19.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 510
Index = 0
Left = 270
TabIndex = 3
Top = 90
Width = 6585
End
Attribute VB_Name = "frmWs_Encrypt"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Text1_Change(Index As Integer)
'This program is based on a javascript program found at "www.hispasec.com/wsftp.asp". Kudos to its author.
'Ws_FTP has a feature that lets you save the password you use to connect to FTP sites. It saves the
'password as an encrypted string in the WS_FTP.ini file. This program can encrypt and decrypted strings
'using the same algorithm that WS_FTP uses. This form serves as a demonstration of the encrypt and decrypt function
'which can be found in modCrypt. modMath has a function that turns Hex strings into integers. I couldn't find
'a function like that in VB.
'This program uses simple crypto algorithms which makes it a good introduciton to encryption techniques
'that are actually being used in commercial programs. If your interested in learning how it works I'll
'get you started by explaining the format of the cyphertext. You can figure out the algorithms by studying
'modCrypt.WS_Decrypt and modCrypt.WS_Encrypt which is quite simple. If you not interested in learning how
'it works you can use
'the functions pretty much as they are. The only thing you should change is the way they handle error detection.
'Here is the cyphertext format:
'PWD=V953A989B6236B3231E395029D36810D1A19B9668
'This string was generated by WS_FTP and decrypts to "head". The "PWD=" is part of the ini file format and
'can not be used in "modCrypt.WS_Decrypt". WS_FTP always generates a "V" as the next character and it has no impact
'on decryption. For each letter in the plaintext there is a salt value in hex (one didgit); in this case "953A".
'Salt values are usually merely randomly generated numbers that make it possible for a plaintext to be encrypted
'into a different ciphertext each time it is encrypted. WS_FTP seems to somehow base its salt values on the plaintext
'which means for each time you encrypt a password in WS_FTP you get the same cyphertext. My program uses randomization for its salts. Moving on, everything past the first
'32 characters of the ciphertext (A19B9668) is the actual encrypted password in hex after it been encrypted with its
'corrosponding salt value. The specific of this are better understood by studying the sourcecode. Everything past the salt(953A)
'and before the encrypted password (A19B9668) are placeholders. WS_FTP places hex numbers here, I suppose, to intimidate the
'cryptanalist. My program puts "X"'s there. You might have noticed that the format only allows for passwords =< then 32 characters.
'Sometimes the encryption function will accept an extended ascii by accident but was not intended for such. You should
'write code that detects both of these possibilities before using it in a program.
If Index = 0 Then Text1(1) = modCrypt.WS_Encrypt(Text1(0))
If Index = 1 Then Text1(2) = modCrypt.WS_Decrypt(Text1(1))